package com.gosophia.conference.action.notification;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.conferenceManagement.notification.dto.NotificationJobDataDTO;
import com.gosophia.conferenceManagement.notification.ws.NotificationWebService;
import com.opensymphony.xwork2.ActionContext;

/**
 *  暂存通知会议Action
 * @author gaoweiguang
 * @since  2011-3-26
 *  Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Scope("prototype")
@Controller("SaveOrUpdateNotificationAction")
public class SaveOrUpdateNotificationAction extends BaseSupportAction{

	private static final long serialVersionUID = -7261670299279132509L;
	@Autowired
	private NotificationWebService notificationWebService;
    
    private NotificationJobDataDTO  notificationJobDataDTO;
    
    private String notificationType;
    
	private String onlinePath;

	private String onlineVersion;

    private Long jobId;

    @Override
    public String _execute() throws Exception {

    	if(notificationType!=null) {
    		notificationJobDataDTO.setNotificationType(notificationType);
    	}
        
    	
		notificationJobDataDTO.setJobId(jobId);
    	if(notificationJobDataDTO.getOnlineDocumentDTO().getDocumentId()==null) {
    		notificationWebService.addNotificationJobData(notificationJobDataDTO);
    		notificationJobDataDTO = notificationWebService.findNotificationJobDataByJobId(jobId);
    	} else {
    		notificationWebService.updateNotificationJobData(notificationJobDataDTO);
    		notificationJobDataDTO = notificationWebService.findNotificationJobDataByJobId(jobId);
    	}
    	
    	super.getRequestResult().setRsltCode("0");
		super.getRequestResult().setMessage("保存成功");
		ActionContext.getContext().getSession().put("_lastOpResult", super.getRequestResult());
    	if("task".equals(this.getFromFlag())) {
    		return "TASK";
    	}
    	 return SUCCESS;
    }

	public NotificationJobDataDTO getNotificationJobDataDTO() {
		return notificationJobDataDTO;
	}

	public void setNotificationJobDataDTO(
			NotificationJobDataDTO notificationJobDataDTO) {
		this.notificationJobDataDTO = notificationJobDataDTO;
	}

	public String getNotificationType() {
		return notificationType;
	}

	public void setNotificationType(String notificationType) {
		this.notificationType = notificationType;
	}

	public Long getJobId() {
		return jobId;
	}

	public void setJobId(Long jobId) {
		this.jobId = jobId;
	}

	public String getOnlinePath() {
		return onlinePath;
	}

	public void setOnlinePath(String onlinePath) {
		this.onlinePath = onlinePath;
	}

	public String getOnlineVersion() {
		return onlineVersion;
	}

	public void setOnlineVersion(String onlineVersion) {
		this.onlineVersion = onlineVersion;
	}


}
